<div class="fixed-bar">
    <form class="layui-form layui-form-pane fixed-bar-form" action="{:url()}" method="get" id="hisi-table-search">
    <div class="layui-form-item">
    	<label class="layui-form-label">搜索</label>
        <div class="layui-input-inline">
            <input type="text" name="keyword" placeholder="sku关键字，按回车搜索" class="layui-input">
        </div>
        <div class="layui-inline">
            <button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">搜索</button>
        </div>
        <div class="layui-inline" style="margin-left:80px;"><a href="{:url('setimg')}" class="layui-btn layui-btn-primary hisi-iframe" hisi-data="{width: '70%', height: '550px'}" title="设置图片">设置图片</a></div>
    </div>
    </form>
</div>

<table id="dataTable" lay-filter='dataTable'></table>

{include file="system@block/layui" /}

<script type="text/html" id="picTpl">
    <img src="{{ d.pic }}" class="lay-pic">
</script>
<script type="text/html" title="操作按钮模板" id="buttonTpl">
    <a href="{:url('print')}?id={{ d.id }}" title="产品打印" class="layui-btn layui-btn-sm layui-btn-normal" target="_blank">产品打印</a><br>
    <a href="{:url('edit')}?id={{ d.id }}" class="layui-btn layui-btn-xs layui-btn-normal hisi-iframe" hisi-data="{width: '70%', height: '550px'}" title="修改产品">修改</a>
	<a href="{:url('del')}?id={{ d.id }}" class="layui-btn layui-btn-xs layui-btn-danger j-tr-del">删除</a>
	{{# if(d.is_public==1){ }}
		<a href="{:url('status')}?id={{ d.id }}&field=is_public&val=0" class="layui-btn layui-btn-xs layui-btn-warm hisi-ajax" refresh="#hisi-table-search">取消公共款</a>
	{{# }else{ }}
		<a href="{:url('status')}?id={{ d.id }}&field=is_public&val=1" class="layui-btn layui-btn-xs layui-btn-normal hisi-ajax" refresh="#hisi-table-search">设为公共款</a>
	{{# } }}

</script>
<script type="text/html" id="toolbar">
    <div class="layui-btn-group fl">
        <a href="{:url('addv2')}" class="layui-btn layui-btn-primary layui-btn-sm layui-icon layui-icon-add-circle-fine hisi-iframe" hisi-data="{width: '70%', height: '550px'}" title="添加产品">&nbsp;添加</a>
		<a data-href="{:url('del')}" class="layui-btn layui-btn-primary layui-btn-sm j-page-btns confirm layui-icon layui-icon-close red">&nbsp;删除</a>
    </div>
</script>

<script type="text/html" id="updateTimeTpl">
    <div>{{layui.util.toDateString(d.update_time * 1000) }}</div>
</script>

<script type="text/javascript">
    layui.use(['table','tool'], function() {
        var table = layui.table;
        table.render({
            elem: '#dataTable'
            ,url: '{:url()}' //数据接口
            ,page: true //开启分页
            ,skin: 'row'
            ,even: true
            ,limit: 20
            ,limits: [20,50,100,150,200]
            ,text: {
                none : '暂无相关数据'
            }
            ,toolbar: '#toolbar'
            ,defaultToolbar: ['filter', 'exports', 'print']
            ,cols: [[ //表头
                {type:'checkbox'}
                ,{field: 'id', title: '编号', sort: true}
                ,{field: 'pic', title: '图片',templet:'#picTpl'}
                ,{field: 'sku', title: 'SKU',width:200,templet:function(d){return '<span class="copy-item">'+d.sku+'</span>'}}
                ,{field: 'tags', title: '标签'}
                ,{field: 'price', title: '售价'}
                ,{field: 'cost', title: '加工费'}
                ,{field: 'is_public', title: '是否公共款',templet:function(d){return layui.tool.formatBool(d.is_public)}}
                ,{field: 'update_time', title: '更新时间',templet: '#updateTimeTpl'}
                ,{title: '操作', templet: '#buttonTpl', fixed: 'right',width:230}
            ]]
        });
    });
</script>